package com.nananer7.servlet;

import com.nananer7.dao.CommentDao;
import com.nananer7.dao.IdeaDao;
import com.nananer7.dao.UserDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class CommentServlet extends HttpServlet{

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        HttpSession session = request.getSession();

        //得到表单提交的内容
        int iid= Integer.parseInt(request.getParameter("iid").trim());
        String username = request.getParameter("username");
        String comment = request.getParameter("comment");


        int uid=new UserDao().findUidByUsername(username);
        boolean bl =new CommentDao().addComment(uid,iid,comment);
        request.getRequestDispatcher("/index.jsp").forward(request, response);


    }
}
